package Entity;

import java.util.List;
import javax.faces.model.ListDataModel;
import org.primefaces.model.SelectableDataModel;

/**
 *
 * @author JuanFelipe
 */
public class TableModelRol extends ListDataModel<Rol> implements SelectableDataModel<Rol>{
    
    public TableModelRol() {  
    }  
  
    public TableModelRol(List<Rol> rol) {  
        super(rol);  
    }  
      
    @Override
    public Rol getRowData(String rowKey) {  
        //In a real app, a more efficient way like a query by rowKey should be implemented to deal with huge data  
          
        List<Rol> roles = (List<Rol>) getWrappedData();  
          
        for(Rol rol : roles) {  
            if(rol.getName().equals(rowKey))  
                return rol;  
        }  
          
        return null;  
    }  
  

    @Override
    public Object getRowKey(Rol rol) {
        return rol.getName();
    }
    
}
